import React, { useEffect } from 'react';
import { Form, Input } from "antd";
import PropTypes from 'prop-types'



const UpdateForm = ({ allFields, setForm, onFieldsDataChange }) =>  {
  const [form] = Form.useForm();

  const onFieldsChange =(changedFields, data) => {
    onFieldsDataChange(data)
  }


  useEffect(() => {
    setForm(form)
  }, [])

  return (
    <div>
      <Form
        name="basic"
        layout="vertical"
        fields={allFields}
        onFieldsChange={onFieldsChange}
        form={form}
      >
        <Form.Item
          label="分类名称"
          name="categoryName"
        >
          <Input  placeholder="请输入分类名称!"/>
        </Form.Item>
      </Form>
    </div>
  );
}

export default UpdateForm;


UpdateForm.propTypes ={
  allFields: PropTypes.array.isRequired,
  setForm: PropTypes.func.isRequired,

}
